<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    function* gen() {
        let a = yield 1;
        console.log(a);
        let b = a + 2; // NaN + 2
        console.log(b);
        if (b > 20) {
            let c = yield 30;
            console.log(c);
        }
        let d = yield b + 10;
        console.log(d);
    }
    const it = gen();
    console.log('next: => ', it.next());
    console.log('next: => ', it.next(10));
    console.log('next: => ', it.next(10));
    console.log('next: => ', it.next(10));
    console.log('next: => ', it.next(10));
    console.log('next: => ', it.next(10));
</script>
</body>
</html>